from flask import Flask
from config import Config
from extensions import db, login_manager, mail

def create_app():
    # 创建Flask应用实例
    app = Flask(__name__)
    app.config.from_object(Config)
    
    # 初始化扩展
    db.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    
    # 注册蓝图
    from auth import auth_bp_zc
    from main import main_bp_zc
    
    app.register_blueprint(auth_bp_zc)
    app.register_blueprint(main_bp_zc)
    
    # 创建数据库表
    with app.app_context():
        db.create_all()
    
    return app

if __name__ == '__main__':
    app = create_app()
    app.run(debug=True) 